package com.example.filemonitor.monitor.runner;

import com.example.filemonitor.monitor.service.IMonitorService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Slf4j
@Service
public class AutoRunMonitor implements  ApplicationRunner {

    @Value("${monitor.rootPath}")
    String rootPath;

    @Resource
    IMonitorService monitorService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("start to auto run......");
        monitorService.monitor(rootPath);
    }
}
